import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:meePet/base/BaseActivity.dart';
import 'package:meePet/base/BaseFragment.dart';
import 'package:webview_flutter/webview_flutter.dart';

class WebFragment extends BaseFragment {
  final String? url;

  WebFragment(this.url);

  @override
  State<StatefulWidget> createState() {
    return WebFragmentState(url);
  }
}

class WebFragmentState extends BaseFragmentState<WebFragment> {
  final String? url;

  WebFragmentState(this.url);

  @override
  Widget initView(BuildContext context) {
    return AnnotatedRegion<SystemUiOverlayStyle>(
      value: const SystemUiOverlayStyle(
/*statusBarColor: Colors.transparent,//状态栏颜色
          statusBarIconBrightness: Brightness.dark, //状态栏图标颜色
          statusBarBrightness: Brightness.dark,  //状态栏亮度
          systemStatusBarContrastEnforced: true, //系统状态栏对比度强制*/

        systemNavigationBarColor: Color.fromRGBO(19, 18, 24, 1),
//导航栏颜色
        systemNavigationBarIconBrightness: Brightness.dark,
//导航栏图标颜色
        systemNavigationBarDividerColor: Color.fromRGBO(19, 18, 24, 1),
//系统导航栏分隔线颜色
        systemNavigationBarContrastEnforced: false, //系统导航栏对比度强制
      ),
      child: getScaffold(context),
    );
  }

  Widget getScaffold(BuildContext context) {
    return Scaffold(
      appBar: null,
      body: _rootLayout(),
    );
  }

  ///根布局
  Widget _rootLayout() {
    return Stack(
      children: [
        SizedBox(
          width: double.infinity,
          height: double.infinity,
          child: DecoratedBox(
              decoration: BoxDecoration(color: Color.fromRGBO(19, 18, 24, 1))),
        ),
        WebView(
            initialUrl: url,
            javascriptMode: JavascriptMode.unrestricted
        )
      ],
    );
  }
}
